home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MACD 5
/
MACD 5.bin
/
workbench
/
wb
/
czesc_2
/
icontools
/
source
/
arp
/
arpbase.j
< prev
Wrap
Text File
|
1992-01-31
|
61KB
|
1,146 lines
\ ArpBase.j
\ AMIGA JForth Include file.
\
\ converted 11/24/89 by R. Mazzarisi using the H2J program by Phil Burke from
\ the JForth Goodies #1 package
\ lines which were unconvertable by the program, which I attempted to
\ convert are marked "correct below? -RM"
\
\ 11/24/89 the only parts tested are the data structures for opening the
\ library and for the functions ArpAllocFreq and FileRequest
\
include? :struct ju:c_struct
decimal
EXISTS? LIBRARIES_ARPBASE_H NOT .IF
1 constant LIBRARIES_ARPBASE_H
.THEN \ %? Forced .THEN to prevent nesting!!!
( )
( ************************************************************************)
( * *)
( * 5/3/89 ARPbase.h by MKSoft from ARPbase.i by SDB *)
( * *)
( ************************************************************************)
( * *)
( * AmigaDOS Resource Project -- Library Include File *)
( * for Lattice C 5.x or Manx C 3.6 *)
( * *)
( ************************************************************************)
( * *)
( * Copyright [c] 1987/1988/1989 by Scott Ballantyne *)
( * *)
( * The arp.library, and related code and files may be freely used *)
( * by supporters of ARP. Modules in the arp.library may not be *)
( * extracted for use in independent code, but you are welcome to *)
( * provide the arp.library with your work and call on it freely. *)
( * *)
( * You are equally welcome to add new functions, improve the ones *)
( * within, or suggest additions. *)
( * *)
( * BCPL programs are not welcome to call on the arp.library. *)
( * The welcome mat is out to all others. *)
( * *)
( ************************************************************************)
( * *)
( * N O T E ! You MUST! have IoErr[] defined as LONG to use LastTracker *)
( * If your compiler has other defines for this, you may wish *)
( * to remove the prototype for IoErr[] from this file. *)
( * *)
( ************************************************************************)
( )
( )
( ************************************************************************)
( * First we need to include the Amiga Standard Include files... *)
( ************************************************************************)
( )
EXISTS? EXEC_TYPES_H NOT .IF
include ji:EXEC/Types.j
.THEN
EXISTS? EXEC_LISTS_H NOT .IF
include ji:EXEC/Lists.j
.THEN
EXISTS? EXEC_ALERTS_H NOT .IF
include ji:EXEC/Alerts.j
.THEN
EXISTS? EXEC_LIBRARIES_H NOT .IF
include ji:EXEC/Libraries.j
.THEN
EXISTS? EXEC_SEMAPHORES_H NOT .IF
include ji:EXEC/Semaphores.j
.THEN
EXISTS? LIBRARIES_DOS_H NOT .IF
include ji:Libraries/DOS.j
.THEN
( )
( ************************************************************************)
( * Standard definitions for arp library information *)
( ************************************************************************)
( )
0" arp.library" 0string ArpName ( Name of library... )
39 constant ArpVersion ( Current version... )
( )
( ************************************************************************)
( * The current ARP library node... *)
( ************************************************************************)
( )
:STRUCT ArpBase
STRUCT Library ab_LibNode ( Standard library node )
APTR ab_DosRootNode ( Copy of dl_Root )
UBYTE ab_Flags ( See bitdefs below )
UBYTE ab_ESCChar ( Character to be used for escaping )
LONG ab_ArpReserved1 ( ArpLib's use only!! )
APTR ab_EnvBase ( Dummy library for MANX compatibility)
APTR ab_DosBase ( Cached DosBase )
APTR ab_GfxBase ( Cached GfxBase )
APTR ab_IntuiBase ( Cached IntuitionBase )
STRUCT MinList ab_ResLists ( Resource trackers )
APTR ab_ResidentPrgList ( Resident Programs. )
STRUCT SignalSemaphore ab_ResPrgProtection ( protection for above )
LONG ab_SegList ( Pointer to loaded libcode [a BPTR]. )
;STRUCT
( )
( ************************************************************************)
( * The following is here *ONLY* for information and for *)
( * compatibility with MANX. DO NOT use in new code! *)
( ************************************************************************)
( )
EXISTS? ARP_PRIVATE .IF
:STRUCT EnvBase
STRUCT Library eb_LibNode ( Standard library node for linkage )
APTR eb_EnvSpace ( Access only when Forbidden! )
ULONG eb_EnvSize ( Total allocated mem for EnvSpace )
APTR eb_ArpBase ( Added in V32 for Resource Tracking )
;STRUCT
.THEN
( )
( ************************************************************************)
( * These are used in release 33.4 but not by the library code. *)
( * Instead, individual programs check for these flags. *)
( ************************************************************************)
( )
0 constant ARPB_WILD_WORLD ( Mixed BCPL/Normal wildcards. )
1 constant ARPB_WILD_BCPL ( Pure BCPL wildcards. )
1 ARPB_WILD_WORLD << constant ARPF_WILD_WORLD
1 ARPB_WILD_BCPL << constant ARPF_WILD_BCPL
( )
( ************************************************************************)
( * The alert object is what you use if you really must return an alert *)
( * to the user. You would normally OR this with another alert number *)
( * from the alerts.h file. Generally, should be NON deadend alerts. *)
( * *)
( * For example, if you can't open ArpLibrary: *)
( * Alert[ [AG_OpenLib|AO_ArpLib], 0L]; *)
( ************************************************************************)
( )
$ 00008036 constant AO_ArpLib ( Alert object )
( )
( ************************************************************************)
( * Alerts that arp.library may return... *)
( ************************************************************************)
( )
$ 03600000 constant AN_ArpLib ( Alert number )
$ 03610000 constant AN_ArpNoMem ( No more memory )
$ 03610002 constant AN_ArpInputMem ( No memory for input buffer )
$ 83610003 constant AN_ArpNoMakeEnv ( No memory to make EnvLib )
$ 83630001 constant AN_ArpNoDOS ( Can't open dos.library )
$ 83630002 constant AN_ArpNoGfx ( Can't open graphics.library )
$ 83630003 constant AN_ArpNoIntuit ( Can't open intuition )
$ 83640000 constant AN_BadPackBlues ( Bad packet returned to SendPacket[] )
$ 83600003 constant AN_Zombie ( Zombie roaming around system )
$ 83600002 constant AN_ArpScattered ( Scatter loading not allowed for arp )
( )
( ************************************************************************)
( * Return codes you can get from calling ARP Assign[]... *)
( ************************************************************************)
( )
0 constant ASSIGN_OK ( Everything is cool and groovey )
1 constant ASSIGN_NODEV ( "Physical" is not valid for assignment )
2 constant ASSIGN_FATAL ( Something really icky happened )
3 constant ASSIGN_CANCEL ( Tried to cancel something but it won't cancel )
( )
( ************************************************************************)
( * Size of buffer you need if you are going to call ReadLine[] *)
( ************************************************************************)
( )
256 constant MaxInputBuf
( )
( ************************************************************************)
( * The ARP file requester data structure... *)
( ************************************************************************)
( )
:STRUCT FileRequester
APTR fr_Hail ( Hailing text )
APTR fr_File ( Filename array [FCHARS + 1] )
APTR fr_Dir ( Directory array [DSIZE + 1] )
APTR fr_Window ( Window requesting or NULL )
UBYTE fr_FuncFlags ( Set bitdef's below )
UBYTE fr_Flags2 ( New flags... )
\ %? correct below? -RM VOID (*fr_Function)(); /* Your function, see bitdef's */
APTR fr_Function() ( Your function, see bitdef's )
SHORT fr_LeftEdge ( To be used later... )
SHORT fr_TopEdge
;STRUCT
( )
( ************************************************************************)
( * The following are the defines for fr_FuncFlags. These bits tell *)
( * FileRequest[] what your fr_UserFunc is expecting, and what *)
( * FileRequest[] should call it for. *)
( * *)
( * You are called like so: *)
( * fr_Function[Mask, Object] *)
( * ULONG Mask; *)
( * CPTR *Object; *)
( * *)
( * The Mask is a copy of the flag value that caused FileRequest[] to *)
( * call your function. You can use this to determine what action you *)
( * need to perform, and exactly what Object is, so you know what to do *)
( * and what to return. *)
( ************************************************************************)
( )
7 constant FRB_DoWildFunc ( Call me with a FIB and a name, ZERO return accepts. )
6 constant FRB_DoMsgFunc ( You get all IDCMP messages not for FileRequest[] )
5 constant FRB_DoColor ( Set this bit for that new and different look )
4 constant FRB_NewIDCMP ( Force a new IDCMP [only if fr_Window != NULL] )
3 constant FRB_NewWindFunc ( You get to modify the newwindow structure. )
2 constant FRB_AddGadFunc ( You get to add gadgets. )
1 constant FRB_GEventFunc ( Function to call if one of your gadgets is selected. )
0 constant FRB_ListFunc ( Not implemented yet. )
1 FRB_DoWildFunc << constant FRF_DoWildFunc
1 FRB_DoMsgFunc << constant FRF_DoMsgFunc
1 FRB_DoColor << constant FRF_DoColor
1 FRB_NewIDCMP << constant FRF_NewIDCMP
1 FRB_NewWindFunc << constant FRF_NewWindFunc
1 FRB_AddGadFunc << constant FRF_AddGadFunc
1 FRB_GEventFunc << constant FRF_GEventFunc
1 FRB_ListFunc << constant FRF_ListFunc
( )
( ************************************************************************)
( * The FR2B_ bits are for fr_Flags2 in the file requester structure *)
( ************************************************************************)
( )
0 constant FR2B_LongPath ( Specify the fr_Dir buffer is 256 bytes long )
1 FR2B_LongPath << constant FR2F_LongPath
( )
( ************************************************************************)
( * The sizes of the different buffers... *)
( ************************************************************************)
( )
32 constant FCHARS ( Filename size )
33 constant DSIZE ( Directory name size if not FR2B_LongPath )
254 constant LONG_DSIZE ( If FR2B_LongPath is set, use LONG_DSIZE )
126 constant LONG_FSIZE ( For compatibility with ARPbase.i )
$ 7680 constant FR_FIRST_GADGET ( User gadgetID's must be less than this value )
( )
( ************************************************************************)
( * Structure expected by FindFirst[]/FindNext[] *)
( * *)
( * You need to allocate this structure and initialize it as follows: *)
( * *)
( * Set ap_BreakBits to the signal bits [CDEF] that you want to take a *)
( * break on, or NULL, if you don't want to convenience the user. *)
( * *)
( * if you want to have the FULL PATH NAME of the files you found, *)
( * allocate a buffer at the END of this structure, and put the size of *)
( * it into ap_StrLen. If you don't want the full path name, make sure *)
( * you set ap_StrLen to zero. In this case, the name of the file, and *)
( * stats are available in the ap_Info, as per usual. *)
( * *)
( * Then call FindFirst[] and then afterwards, FindNext[] with this *)
( * structure. You should check the return value each time [see below] *)
( * and take the appropriate action, ultimately calling *)
( * FreeAnchorChain[] when there are no more files and you are done. *)
( * You can tell when you are done by checking for the normal AmigaDOS *)
( * return code ERROR_NO_MORE_ENTRIES. *)
( * *)
( * You will also have to check the DirEntryType variable in the ap_Info *)
( * structure to determine what exactly you have received. *)
( ************************************************************************)
( )
:STRUCT AnchorPath
APTR ap_Base ( Pointer to first anchor )
APTR ap_Last ( Pointer to last anchor )
LONG ap_BreakBits ( Bits to break on )
LONG ap_FoundBreak ( Bits we broke on. Also returns ERROR_BREAK )
BYTE ap_Flags ( New use for the extra word... )
BYTE ap_Reserved ( To fill it out... )
SHORT ap_StrLen ( This is what used to be ap_Length )
STRUCT FileInfoBlock ap_Info
( %?) 1 BYTES ap_Buf ( Allocate a buffer here, if desired )
;STRUCT
( )
( ************************************************************************)
( * Bit definitions for the new ap_Flags... *)
( ************************************************************************)
( )
0 constant APB_DoWild ( User option ALL )
1 constant APB_ItsWild ( Set by FindFirst, used by FindNext )
2 constant APB_DoDir ( Bit is SET if a DIR node should be entered )
( Application can RESET this bit to AVOID )
( entering a dir. )
3 constant APB_DidDir ( Bit is set for an "expired" dir node )
4 constant APB_NoMemErr ( Set if there was not enough memory )
5 constant APB_DoDot ( If set, '.' [DOT] will convert to CurrentDir )
1 APB_DoWild << constant APF_DoWild
1 APB_ItsWild << constant APF_ItsWild
1 APB_DoDir << constant APF_DoDir
1 APB_DidDir << constant APF_DidDir
1 APB_NoMemErr << constant APF_NoMemErr
1 APB_DoDot << constant APF_DoDot
( )
( ************************************************************************)
( * Structure used by the pattern matching functions, no need to obtain, *)
( * diddle or allocate this yourself. *)
( * *)
( * Note: If you did, you will now break as it has changed... *)
( ************************************************************************)
( )
EXISTS? ARP_PRIVATE .IF
:STRUCT AChain
APTR an_Child
APTR an_Parent
APTR an_Lock
APTR an_Info
BYTE an_Flags
( %?) 1 BYTES an_String ( Just as is .i file )
;STRUCT
( ??? Don't use this! )
.THEN
0 constant DDB_PatternBit
1 constant DDB_ExaminedBit
2 constant DDB_Completed
3 constant DDB_AllBit
1 DDB_PatternBit << constant DDF_PatternBit
1 DDB_ExaminedBit << constant DDF_ExaminedBit
1 DDB_Completed << constant DDF_Completed
1 DDB_AllBit << constant DDF_AllBit
( )
( ************************************************************************)
( * This structure takes a pointer, and returns FALSE if wildcard was *)
( * not found by FindFirst[] *)
( ************************************************************************)
( )
\ %? #define IsWild( ptr ) ( *((LONG *)(ptr)) ): IsWild ;
( )
( ************************************************************************)
( * Constants used by wildcard routines *)
( * *)
( * These are the pre-parsed tokens referred to by pattern match. It *)
( * is not necessary for you to do anything about these, FindFirst[] *)
( * FindNext[] handle all these for you. *)
( ************************************************************************)
( )
$ 80 constant P_ANY ( Token for '*' | '#?' )
$ 81 constant P_SINGLE ( Token for '?' )
( )
( ************************************************************************)
( * No need to muck with these as they may change... *)
( ************************************************************************)
( )
EXISTS? ARP_PRIVATE .IF
$ 82 constant P_ORSTART ( Token for '[' )
$ 83 constant P_ORNEXT ( Token for '|' )
$ 84 constant P_OREND ( Token for ']' )
$ 85 constant P_NOT ( Token for '~' )
$ 87 constant P_NOTCLASS ( Token for '^' )
$ 88 constant P_CLASS ( Token for '[]' )
$ 89 constant P_REPBEG ( Token for '[' )
$ 8A constant P_REPEND ( Token for ']' )
.THEN
( )
( ************************************************************************)
( * Structure used by AddDANode[], AddDADevs[], FreeDAList[]. *)
( * *)
( * This structure is used to create lists of names, which normally *)
( * are devices, assigns, volumes, files, or directories. *)
( ************************************************************************)
( )
:STRUCT DirectoryEntry
APTR de_Next ( Next in list )
BYTE de_Type ( DLX_mumble )
BYTE de_Flags ( For future expansion, DO NOT USE! )
( %?) 1 BYTES de_Name ( The name of the thing found )
;STRUCT
( )
( ************************************************************************)
( * Defines you use to get a list of the devices you want to look at. *)
( * For example, to get a list of all directories and volumes, do: *)
( * *)
( * AddDADevs[ mydalist, [DLF_DIRS | DLF_VOLUMES] ] *)
( * *)
( * After this, you can examine the de_type field of the elements added *)
( * to your list [if any] to discover specifics about the objects added. *)
( * *)
( * Note that if you want only devices which are also disks, you must *)
( * [DLF_DEVICES | DLF_DISKONLY]. *)
( ************************************************************************)
( )
0 constant DLB_DEVICES ( Return devices )
1 constant DLB_DISKONLY ( Modifier for above: Return disk devices only )
2 constant DLB_VOLUMES ( Return volumes only )
3 constant DLB_DIRS ( Return assigned devices only )
1 DLB_DEVICES << constant DLF_DEVICES
1 DLB_DISKONLY << constant DLF_DISKONLY
1 DLB_VOLUMES << constant DLF_VOLUMES
1 DLB_DIRS << constant DLF_DIRS
( )
( ************************************************************************)
( * Legal de_Type values, check for these after a call to AddDADevs[], *)
( * or use on your own as the ID values in AddDANode[]. *)
( ************************************************************************)
( )
0 constant DLX_FILE ( AddDADevs[] can't determine this )
8 constant DLX_DIR ( AddDADevs[] can't determine this )
16 constant DLX_DEVICE ( It's a resident device )
24 constant DLX_VOLUME ( Device is a volume )
32 constant DLX_UNMOUNTED ( Device is not resident )
40 constant DLX_ASSIGN ( Device is a logical assignment )
( )
( ************************************************************************)
( * This macro is to check for an error return from the Atol[] *)
( * routine. If Errno is ERRBADINT, then there was an error... *)
( * This was done to try to remain as close to source compatible *)
( * as possible with the older [rel 1.1] ARPbase.h *)
( ************************************************************************)
( )
1 constant ERRBADINT
\ %? #define Errno (IoErr() ? ERRBADINT : 0)
( )
( ************************************************************************)
( * Resource Tracking stuff... *)
( ************************************************************************)
( * *)
( * There are a few things in arp.library that are only directly *)
( * acessable from assembler. The glue routines provided by us for *)
( * all 'C' compilers use the following conventions to make these *)
( * available to C programs. The glue for other language's should use *)
( * as similar a mechanism as possible, so that no matter what language *)
( * or compiler we speak, when talk about arp, we will know what the *)
( * other guy is saying. *)
( * *)
( * Here are the cases: *)
( * *)
( * Tracker calls... *)
( * These calls return the Tracker pointer as a secondary *)
( * result in the register A1. For C, there is no clean *)
( * way to return more than one result so the tracker *)
( * pointer is returned in IoErr[]. For ease of use, *)
( * there is a define that typecasts IoErr[] to the correct *)
( * pointer type. This is called LastTracker and should *)
( * be source compatible with the earlier method of storing *)
( * the secondary result. *)
( * *)
( * GetTracker[] - *)
( * Syntax is a bit different for C than the assembly call *)
( * The C syntax is GetTracker[ID]. The binding routines *)
( * will store the ID into the tracker on return. Also, *)
( * in an effort to remain consistant, the tracker will *)
( * also be stored in LastTracker. *)
( * *)
( * In cases where you have allocated a tracker before you have obtained *)
( * a resource [usually the most efficient method], and the resource has *)
( * not been obtained, you will need to clear the tracker id. The macro *)
( * CLEAR_ID[] has been provided for that purpose. It expects a pointer *)
( * to a DefaultTracker sort of struct. *)
( ************************************************************************)
( )
\ %? #define CLEAR_ID(t) ((SHORT *) t)[-1]=NULL: CLEAR_ID ;
( )
( ************************************************************************)
( * You MUST prototype IoErr[] to prevent the possible error in defining *)
( * IoErr[] and thus causing LastTracker to give you trash... *)
( * *)
( * N O T E ! You MUST! have IoErr[] defined as LONG to use LastTracker *)
( * If your compiler has other defines for this, you may wish *)
( * to remove the prototype for IoErr[]. *)
( ************************************************************************)
( )
\ %? #define LastTracker ((struct DefaultTracker *)IoErr())
( )
( ************************************************************************)
( * The rl_FirstItem list [ResList] is a list of TrackedResource [below] *)
( * It is very important that nothing in this list depend on the task *)
( * existing at resource freeing time [i.e., RemTask[0L] type stuff, *)
( * DeletePort[] and the rest]. *)
( * *)
( * The tracking functions return a struct Tracker *Tracker to you, this *)
( * is a pointer to whatever follows the tr_ID variable. *)
( * The default case is reflected below, and you get it if you call *)
( * GetTracker[] [ see DefaultTracker below]. *)
( * *)
( * NOTE: The two user variables mentioned in an earlier version don't *)
( * exist, and never did. Sorry about that [SDB]. *)
( * *)
( * However, you can still use ArpAlloc[] to allocate your own tracking *)
( * nodes and they can be any size or shape you like, as long as the *)
( * base structure is preserved. They will be freed automagically just *)
( * like the default trackers. *)
( ************************************************************************)
( )
:STRUCT TrackedResource
STRUCT MinNode tr_Node ( Double linked pointer )
BYTE tr_Flags ( Don't touch )
BYTE tr_Lock ( Don't touch, for Get/FreeAccess[] )
SHORT tr_ID ( Item's ID )
( )
( ************************************************************************)
( * The struct DefaultTracker *Tracker portion of the structure. *)
( * The stuff below this point can conceivably vary, depending *)
( * on user needs, etc. This reflects the default. *)
( ************************************************************************)
( )
union{
\ %? correct below? -RM CPTR tr_Resource; /* Whatever */
APTR tr_Resource ( Whatever )
}union{
LONG tg_Verify ( For use during TRAK_GENERIC )
}union \ tr_Object; /* The thing being tracked */
union{
\ %? correct below? -RM VOID (*tg_Function)();/* Function to call for TRAK_GENERIC */
APTR tg_Function() ( Function to call for TRAK_GENERIC )
}union{
APTR tr_Window2 ( For TRAK_WINDOW )
}union \ tr_Extra; /* Only needed sometimes */
;STRUCT
\ %? #define tg_Value tg_Verify /* Ancient compatibility only! Do NOT use in new CODE!!! */
( )
( ************************************************************************)
( * You get a pointer to a struct of the following type when you call *)
( * GetTracker[]. You can change this, and use ArpAlloc[] instead of *)
( * GetTracker[] to do tracking. Of course, you have to take a wee bit *)
( * more responsibility if you do, as well as if you use TRAK_GENERIC *)
( * stuff. *)
( * *)
( * TRAK_GENERIC folks need to set up a task function to be called when *)
( * an item is freed. Some care is required to set this up properly. *)
( * *)
( * Some special cases are indicated by the unions below, for *)
( * TRAK_WINDOW, if you have more than one window opened, and don't *)
( * want the IDCMP closed particularly, you need to set a ptr to the *)
( * other window in dt_Window2. See CloseWindowSafely[] for more info. *)
( * If only one window, set this to NULL. *)
( ************************************************************************)
( )
:STRUCT DefaultTracker
union{
\ %? correct below? -RM CPTR dt_Resource; /* Whatever */
APTR dt_Resource ( Whatever )
}union{
LONG tg_Verify ( For use during TRAK_GENERIC )
}union \ dt_Object; /* The object being tracked */
union{
\ %? correct below? -RM VOID (*tg_Function)();/* Function to call for TRAK_GENERIC */
APTR tg_Function() ( Function to call for TRAK_GENERIC )
}union{
APTR dt_Window2 ( For TRAK_WINDOW )
}union \ dt_Extra;
;STRUCT
( )
( ************************************************************************)
( * Items the tracker knows what to do about *)
( ************************************************************************)
( )
0 constant TRAK_AAMEM ( Default [ArpAlloc] element )
1 constant TRAK_LOCK ( File lock )
2 constant TRAK_FILE ( Opened file )
3 constant TRAK_WINDOW ( Window -- see docs )
4 constant TRAK_SCREEN ( Screen )
5 constant TRAK_LIBRARY ( Opened library )
6 constant TRAK_DAMEM ( Pointer to DosAllocMem block )
7 constant TRAK_MEMNODE ( AllocEntry[] node )
8 constant TRAK_SEGLIST ( Program segment )
9 constant TRAK_RESLIST ( ARP [nested] ResList )
10 constant TRAK_MEM ( Memory ptr/length )
11 constant TRAK_GENERIC ( Generic Element, your choice )
12 constant TRAK_DALIST ( DAlist [ aka file request ] )
13 constant TRAK_ANCHOR ( Anchor chain [pattern matching] )
14 constant TRAK_FREQ ( FileRequest struct )
15 constant TRAK_FONT ( GfxBase CloseFont[] )
15 constant TRAK_MAX ( Poof, anything higher is tossed )
7 constant TRB_UNLINK ( Free node bit )
6 constant TRB_RELOC ( This may be relocated [not used yet] )
5 constant TRB_MOVED ( Item moved )
1 TRB_UNLINK << constant TRF_UNLINK
1 TRB_RELOC << constant TRF_RELOC
1 TRB_MOVED << constant TRF_MOVED
( )
( ************************************************************************)
( * Note: ResList MUST be a DosAllocMem'ed list!, this is done for *)
( * you when you call CreateTaskResList[], typically, you won't need *)
( * to access/allocate this structure. *)
( ************************************************************************)
( )
:STRUCT ResList
STRUCT MinNode rl_Node ( Used by arplib to link reslists )
APTR rl_TaskID ( Owner of this list )
STRUCT MinList rl_FirstItem ( List of Tracked Resources )
APTR rl_Link ( SyncRun's use - hide list here )
;STRUCT
( )
( ************************************************************************)
( * Returns from CompareLock[] *)
( ************************************************************************)
( )
0 constant LCK_EQUAL ( The two locks refer to the same object )
1 constant LCK_VOLUME ( Locks are on the same volume )
2 constant LCK_DIFVOL1 ( Locks are on different volumes )
3 constant LCK_DIFVOL2 ( Locks are on different volumes )
( )
( ************************************************************************)
( * ASyncRun[] stuff... *)
( ************************************************************************)
( * Message sent back on your request by an exiting process. *)
( * You request this by putting the address of your message in *)
( * pcb_LastGasp, and initializing the ReplyPort variable of your *)
( * ZombieMsg to the port you wish the message posted to. *)
( ************************************************************************)
( )
:STRUCT ZombieMsg
STRUCT Message zm_ExecMessage
ULONG zm_TaskNum ( Task ID )
LONG zm_ReturnCode ( Process's return code )
ULONG zm_Result2 ( System return code )
STRUCT DateStamp zm_ExitTime ( Date stamp at time of exit )
ULONG zm_UserInfo ( For whatever you wish )
;STRUCT
( )
( ************************************************************************)
( * Structure required by ASyncRun[] -- see docs for more info. *)
( ************************************************************************)
( )
:STRUCT ProcessControlBlock
ULONG pcb_StackSize ( Stacksize for new process )
BYTE pcb_Pri ( Priority of new task )
UBYTE pcb_Control ( Control bits, see defines below )
APTR pcb_TrapCode ( Optional Trap Code )
LONG pcb_Input
LONG pcb_Output ( Optional stdin, stdout )
union{
LONG pcb_SplatFile ( File to use for Open["*"] )
}union{
APTR pcb_ConName ( CON: filename )
}union \ pcb_Console;
\ %? CPTR pcb_LoadedCode; /* If not null, will not load/unload code */
APTR pcb_LoadedCode ( If not null, will not load/unload code )
APTR pcb_LastGasp ( ReplyMsg[] to be filled in by exit )
APTR pcb_WBProcess ( Valid only when PRB_NOCLI )
;STRUCT
( )
( ************************************************************************)
( * Formerly needed to pass NULLCMD to a child. No longer needed. *)
( * It is being kept here for compatibility only... *)
( ************************************************************************)
( )
\ %? #define NOCMD "\n"
( )
( ************************************************************************)
( * The following control bits determine what ASyncRun[] does on *)
( * Abnormal Exits and on background process termination. *)
( ************************************************************************)
( )
0 constant PRB_SAVEIO ( Don't free/check file handles on exit )
1 constant PRB_CLOSESPLAT ( Close Splat file, must request explicitly )
2 constant PRB_NOCLI ( Don't create a CLI process )
( PRB_INTERACTIVE 3L This is now obsolete... )
4 constant PRB_CODE ( Dangerous yet enticing )
5 constant PRB_STDIO ( Do the stdio thing, splat = CON:Filename )
1 PRB_SAVEIO << constant PRF_SAVEIO
1 PRB_CLOSESPLAT << constant PRF_CLOSESPLAT
1 PRB_NOCLI << constant PRF_NOCLI
1 PRB_CODE << constant PRF_CODE
1 PRB_STDIO << constant PRF_STDIO
( )
( ************************************************************************)
( * Error returns from SyncRun[] and ASyncRun[] *)
( ************************************************************************)
( )
-1 constant PR_NOFILE ( Could not LoadSeg[] the file )
-2 constant PR_NOMEM ( No memory for something )
( PR_NOCLI -3L This is now obsolete )
-4 constant PR_NOSLOT ( No room in TaskArray )
-5 constant PR_NOINPUT ( Could not open input file )
-6 constant PR_NOOUTPUT ( Could not get output file )
( PR_NOLOCK -7L This is now obsolete )
( PR_ARGERR -8L This is now obsolete )
( PR_NOBCPL -9L This is now obsolete )
( PR_BADLIB -10L This is now obsolete )
-11 constant PR_NOSTDIO ( Couldn't get stdio handles )
( )
( ************************************************************************)
( * Added V35 of arp.library *)
( ************************************************************************)
( )
-12 constant PR_WANTSMESSAGE ( Child wants you to report IoErr[] to user )
( for SyncRun[] only... )
-13 constant PR_NOSHELLPROC ( Can't create a shell/cli process )
-14 constant PR_NOEXEC ( 'E' bit is clear )
-15 constant PR_SCRIPT ( S and E are set, IoErr[] contains directory )
( )
( ************************************************************************)
( * Version 35 ASyncRun[] allows you to create an independent *)
( * interactive or background Shell/CLI. You need this variant of the *)
( * pcb structure to do it, and you also have new values for nsh_Control,*)
( * see below. *)
( * *)
( * Syntax for Interactive shell is: *)
( * *)
( * rc=ASyncRun["Optional Window Name","Optional From File",&NewShell]; *)
( * *)
( * Syntax for a background shell is: *)
( * *)
( * rc=ASyncRun["Command line",0L,&NewShell]; *)
( * *)
( * Same syntax for an Execute style call, but you have to be on drugs *)
( * if you want to do that. *)
( ************************************************************************)
( )
:STRUCT NewShell
ULONG nsh_StackSize ( stacksize shell will use for children )
BYTE nsh_Pri ( ignored by interactive shells )
UBYTE nsh_Control ( bits/values: see above )
\ %? correct below? -RM CPTR nsh_LogMsg; /* Optional login message, if null, use default */
APTR nsh_LogMsg ( Optional login message, if null, use default )
LONG nsh_Input ( ignored by interactive shells, but )
LONG nsh_Output ( used by background and execute options. )
( %?) 5 4 * BYTES nsh_RESERVED
;STRUCT
( )
( ************************************************************************)
( * Bit Values for nsh_Control, you should use them as shown below, or *)
( * just use the actual values indicated. *)
( ************************************************************************)
( )
0 constant PRB_CLI ( Do a CLI, not a shell )
1 constant PRB_BACKGROUND ( Background shell )
2 constant PRB_EXECUTE ( Do as EXECUTE... )
3 constant PRB_INTERACTIVE ( Run an interactive shell )
7 constant PRB_FB ( Alt function bit... )
1 PRB_CLI << constant PRF_CLI
1 PRB_BACKGROUND << constant PRF_BACKGROUND
1 PRB_EXECUTE << constant PRF_EXECUTE
1 PRB_INTERACTIVE << constant PRF_INTERACTIVE
1 PRB_FB << constant PRF_FB
( )
( ************************************************************************)
( * Common values for sh_Control which allow you to do usefull *)
( * and somewhat "standard" things... *)
( ************************************************************************)
( )
PRF_FB PRF_INTERACTIVE | constant INTERACTIVE_SHELL ( Gimme a newshell! )
PRF_FB PRF_INTERACTIVE | PRF_CLI | constant INTERACTIVE_CLI ( Gimme that ol newcli! )
PRF_FB PRF_BACKGROUND | constant BACKGROUND_SHELL ( gimme a background shell )
PRF_FB PRF_BACKGROUND | PRF_EXECUTE | constant EXECUTE_ME ( aptly named, doncha think? )
( )
( ************************************************************************)
( * Additional IoErr[] returns added by ARP... *)
( ************************************************************************)
( )
303 constant ERROR_BUFFER_OVERFLOW ( User or internal buffer overflow )
304 constant ERROR_BREAK ( A break character was received )
305 constant ERROR_NOT_EXECUTABLE ( A file has E bit cleared )
400 constant ERROR_NOT_CLI ( Program/function neeeds to be cli )
( )
( ************************************************************************)
( * Resident Program Support *)
( ************************************************************************)
( * This is the kind of node allocated for you when you AddResidentPrg[] *)
( * a code segment. They are stored as a single linked list with the *)
( * root in ArpBase. If you absolutely *must* wander through this list *)
( * instead of using the supplied functions, then you must first obtain *)
( * the semaphore which protects this list, and then release it *)
( * afterwards. Do not use Forbid[] and Permit[] to gain exclusive *)
( * access! Note that the supplied functions handle this locking *)
( * protocol for you. *)
( ************************************************************************)
( )
:STRUCT ResidentProgramNode
APTR rpn_Next ( next or NULL )
LONG rpn_Usage ( Number of current users )
USHORT rpn_AccessCnt ( Total times used... )
ULONG rpn_CheckSum ( Checksum of code )
LONG rpn_Segment ( Actual segment )
USHORT rpn_Flags ( See definitions below... )
( %?) 1 BYTES rpn_Name ( Allocated as needed )
;STRUCT
( )
( ************************************************************************)
( * Bit definitions for rpn_Flags.... *)
( ************************************************************************)
( )
0 constant RPNB_NOCHECK ( Set in rpn_Flags for no checksumming... )
1 constant RPNB_CACHE ( Private usage in v1.3... )
1 RPNB_NOCHECK << constant RPNF_NOCHECK
1 RPNB_CACHE << constant RPNF_CACHE
( )
( ************************************************************************)
( * If your program starts with this structure, ASyncRun[] and SyncRun[] *)
( * will override a users stack request with the value in rpt_StackSize. *)
( * Furthermore, if you are actually attached to the resident list, a *)
( * memory block of size rpt_DataSize will be allocated for you, and *)
( * a pointer to this data passed to you in register A4. You may use *)
( * this block to clone the data segment of programs, thus resulting in *)
( * one copy of text, but multiple copies of data/bss for each process *)
( * invocation. If you are resident, your program will start at *)
( * rpt_Instruction, otherwise, it will be launched from the initial *)
( * branch. *)
( ************************************************************************)
( )
:STRUCT ResidentProgramTag
LONG rpt_NextSeg ( Provided by DOS at LoadSeg time )
( )
( ************************************************************************)
( * The initial branch destination and rpt_Instruction do not have to be *)
( * the same. This allows different actions to be taken if you are *)
( * diskloaded or resident. DataSize memory will be allocated only if *)
( * you are resident, but StackSize will override all user stack *)
( * requests. *)
( ************************************************************************)
( )
USHORT rpt_BRA ( Short branch to executable )
USHORT rpt_Magic ( Resident majik value )
ULONG rpt_StackSize ( min stack for this process )
ULONG rpt_DataSize ( Data size to allocate if resident )
( rpt_Instruction; Start here if resident )
;STRUCT
( )
( ************************************************************************)
( * The form of the ARP allocated node in your tasks memlist when *)
( * launched as a resident program. Note that the data portion of the *)
( * node will only exist if you have specified a nonzero value for *)
( * rpt_DataSize. Note also that this structure is READ ONLY, modify *)
( * values in this at your own risk. The stack stuff is for tracking, *)
( * if you need actual addresses or stack size, check the normal places *)
( * for it in your process/task struct. *)
( ************************************************************************)
( )
:STRUCT ProcessMemory
STRUCT Node pm_Node
USHORT pm_Num ( This is 1 if no data, two if data )
\ %? correct below? -RM CPTR pm_Stack;
APTR pm_Stack
ULONG pm_StackSize
\ %? correct below? -RM CPTR pm_Data; /* Only here if pm_Num == 2 */
APTR pm_Data ( Only here if pm_Num == 2 )
ULONG pm_DataSize
;STRUCT
( )
( ************************************************************************)
( * To find the above on your memlist, search for the following name. *)
( * We guarantee this will be the only arp.library allocated node on *)
( * your memlist with this name. *)
( * i.e. FindName[task->tcb_MemEntry, PMEM_NAME]; *)
( ************************************************************************)
( )
0" ARP_MEM" 0string PMEM_NAME
$ 4AFC constant RESIDENT_MAGIC ( same as RTC_MATCHWORD [trapf] )
( )
( ************************************************************************)
( * Date String/Data structures *)
( ************************************************************************)
( )
:STRUCT DateTime
STRUCT DateStamp dat_Stamp ( DOS Datestamp )
UBYTE dat_Format ( controls appearance ot dat_StrDate )
UBYTE dat_Flags ( See BITDEF's below )
APTR dat_StrDay ( day of the week string )
APTR dat_StrDate ( date string )
APTR dat_StrTime ( time string )
;STRUCT
( )
( ************************************************************************)
( * Size of buffer you need for each DateTime strings: *)
( ************************************************************************)
( )
10 constant LEN_DATSTRING
( )
( ************************************************************************)
( * For dat_Flags *)
( ************************************************************************)
( )
0 constant DTB_SUBST ( Substitute "Today" "Tomorrow" where appropriate )
1 constant DTB_FUTURE ( Day of the week is in future )
1 DTB_SUBST << constant DTF_SUBST
1 DTB_FUTURE << constant DTF_FUTURE
( )
( ************************************************************************)
( * For dat_Format *)
( ************************************************************************)
( )
0 constant FORMAT_DOS ( dd-mmm-yy AmigaDOS's own, unique style )
1 constant FORMAT_INT ( yy-mm-dd International format )
2 constant FORMAT_USA ( mm-dd-yy The good'ol'USA. )
3 constant FORMAT_CDN ( dd-mm-yy Our brothers and sisters to the north )
FORMAT_CDN constant FORMAT_MAX ( Larger than this? Defaults to AmigaDOS )
( )
( ************************************************************************)
( * This prototype is here to prevent the possible error in defining *)
( * IoErr[] as LONG and thus causing LastTracker to give you trash... *)
( * *)
( * N O T E ! You MUST! have IoErr[] defined as LONG to use LastTracker *)
( * If your compiler has other defines for this, you may wish *)
( * to move the prototype for IoErr[] into the DO_ARP_COPIES *)
( ************************************************************************)
( )
\ %? LONG IoErr ARGs( (VOID) );
\ %? /*
\ %? * These duplicate the calls in dos.library *
\ %? * Only include if you can use arp.library without dos.library *
\ %? */
\ %? #ifdef DO_ARP_COPIES
\ %? BPTR Open ARGs( (char *, LONG) );
\ %? VOID Close ARGs( (BPTR) );
\ %? LONG Read ARGs( (BPTR, char *, LONG) );
\ %? LONG Write ARGs( (BPTR, char *, LONG) );
\ %? BPTR Input ARGs( (VOID) );
\ %? BPTR Output ARGs( (VOID) );
\ %? LONG Seek ARGs( (BPTR, LONG, LONG) );
\ %? LONG DeleteFile ARGs( (char *) );
\ %? LONG Rename ARGs( (char *, char *) );
\ %? BPTR Lock ARGs( (char *, LONG) );
\ %? VOID UnLock ARGs( (BPTR) );
\ %? BPTR DupLock ARGs( (BPTR) );
\ %? LONG Examine ARGs( (BPTR, struct FileInfoBlock *) );
\ %? LONG ExNext ARGs( (BPTR, struct FileInfoBlock *) );
\ %? LONG Info ARGs( (BPTR, struct InfoData *) );
\ %? BPTR CreateDir ARGs( (char *) );
\ %? BPTR CurrentDir ARGs( (BPTR) );
\ %? struct MsgPort *CreateProc ARGs( (char *, LONG, BPTR, LONG) );
\ %? VOID Exit ARGs( (LONG) );
\ %? BPTR LoadSeg ARGs( (char *) );
\ %? VOID UnLoadSeg ARGs( (BPTR) );
\ %? struct MsgPort *DeviceProc ARGs( (char *) );
\ %? LONG SetComment ARGs( (char *, char *) );
\ %? LONG SetProtection ARGs( (char *, LONG) );
\ %? LONG *DateStamp ARGs( (LONG *) );
\ %? VOID Delay ARGs( (LONG) );
\ %? LONG WaitForChar ARGs( (BPTR, LONG) );
\ %? BPTR ParentDir ARGs( (BPTR) );
\ %? LONG IsInteractive ARGs( (BPTR) );
\ %? LONG Execute ARGs( (char *, BPTR, BPTR) );
\ %? #endif DO_ARP_COPIES
\ %? /*
\ %? * Now for the stuff that only exists in arp.library... *
\ %? */
\ %? LONG C_Args Printf ARGs( (char *,) );
\ %? LONG C_Args FPrintf ARGs( (BPTR, char *,) );
\ %? LONG Puts ARGs( (char *) );
\ %? LONG Readline ARGs( (char *) );
\ %? LONG GADS ARGs( (char *, LONG, char *, char **, char *) );
\ %? LONG Atol ARGs( (char *) );
\ %? ULONG EscapeString ARGs( (char *) );
\ %? LONG CheckAbort ARGs( (VOID(*)) );
\ %? LONG CheckBreak ARGs( (LONG, VOID(*)) );
\ %? BYTE *Getenv ARGs( (char *, char *, LONG) );
\ %? BOOL Setenv ARGs( (char *, char *) );
\ %? BYTE *FileRequest ARGs( (struct FileRequester *) );
\ %? VOID CloseWindowSafely ARGs( (struct Window *, LONG) );
\ %? struct MsgPort *CreatePort ARGs( (char *, LONG) );
\ %? VOID DeletePort ARGs( (struct MsgPort *) );
\ %? LONG SendPacket ARGs( (LONG, LONG *, struct MsgPort *) );
\ %? VOID InitStdPacket ARGs( (LONG, LONG *, struct DosPacket *, struct MsgPort *) );
\ %? ULONG PathName ARGs( (BPTR, char *,LONG) );
\ %? ULONG Assign ARGs( (char *, char *) );
\ %? VOID *DosAllocMem ARGs( (LONG) );
\ %? VOID DosFreeMem ARGs( (VOID *) );
\ %? ULONG BtoCStr ARGs( (char *, BSTR, LONG) );
\ %? ULONG CtoBStr ARGs( (char *, BSTR, LONG) );
\ %? struct DeviceList *GetDevInfo ARGs( (struct DeviceList *) );
\ %? BOOL FreeTaskResList ARGs( (VOID) );
\ %? VOID ArpExit ARGs( (LONG,LONG) );
\ %? VOID C_Args *ArpAlloc ARGs( (LONG) );
\ %? VOID C_Args *ArpAllocMem ARGs( (LONG, LONG) );
\ %? BPTR C_Args ArpOpen ARGs( (char *, LONG) );
\ %? BPTR C_Args ArpDupLock ARGs( (BPTR) );
\ %? BPTR C_Args ArpLock ARGs( (char *, LONG) );
\ %? VOID C_Args *RListAlloc ARGs( (struct ResList *, LONG) );
\ %? struct Process *FindCLI ARGs( (LONG) );
\ %? BOOL QSort ARGs( (VOID *, LONG, LONG, int(*)) );
\ %? BOOL PatternMatch ARGs( (char *,char *) );
\ %? LONG FindFirst ARGs( (char *, struct AnchorPath *) );
\ %? LONG FindNext ARGs( (struct AnchorPath *) );
\ %? VOID FreeAnchorChain ARGs( (struct AnchorPath *) );
\ %? ULONG CompareLock ARGs( (BPTR, BPTR) );
\ %? struct ResList *FindTaskResList ARGs( (VOID) );
\ %? struct ResList *CreateTaskResList ARGs( (VOID) );
\ %? VOID FreeResList ARGs( (struct ResList *) );
\ %? VOID FreeTrackedItem ARGs( (struct DefaultTracker *) );
\ %? struct DefaultTracker C_Args *GetTracker ARGs( (LONG) );
\ %? VOID *GetAccess ARGs( (struct DefaultTracker *) );
\ %? VOID FreeAccess ARGs( (struct DefaultTracker *) );
\ %? VOID FreeDAList ARGs( (struct DirectoryEntry *) );
\ %? struct DirectoryEntry *AddDANode ARGs( (char *, struct DirectoryEntry **, LONG, LONG) );
\ %? ULONG AddDADevs ARGs( (struct DirectoryEntry **, LONG) );
\ %? LONG Strcmp ARGs( (char *, char *) );
\ %? LONG Strncmp ARGs( (char *, char *, LONG) );
\ %? BYTE Toupper ARGs( (BYTE) );
\ %? LONG SyncRun ARGs( (char *, char *, BPTR, BPTR) );
\ %? /*
\ %? * Added V32 of arp.library *
\ %? */
\ %? LONG ASyncRun ARGs( (char *, char *, struct ProcessControlBlock *) );
\ %? LONG SpawnShell ARGs( (char *, char *, struct NewShell *) );
\ %? BPTR LoadPrg ARGs( (char *) );
\ %? BOOL PreParse ARGs( (char *, char *) );
\ %? /*
\ %? * Added V33 of arp.library *
\ %? */
\ %? BOOL StamptoStr ARGs( (struct DateTime *) );
\ %? BOOL StrtoStamp ARGs( (struct DateTime *) );
\ %? struct ResidentProgramNode *ObtainResidentPrg ARGs( (char *) );
\ %? struct ResidentProgramNode *AddResidentPrg ARGs( (BPTR, char *) );
\ %? LONG RemResidentPrg ARGs( (char *) );
\ %? VOID UnLoadPrg ARGs( (BPTR) );
\ %? LONG LMult ARGs( (LONG, LONG) );
\ %? LONG LDiv ARGs( (LONG, LONG) );
\ %? LONG LMod ARGs( (LONG, LONG) );
\ %? ULONG CheckSumPrg ARGs( (struct ResidentProgramNode *) );
\ %? VOID TackOn ARGs( (char *, char *) );
\ %? BYTE *BaseName ARGs( (char *) );
\ %? struct ResidentProgramNode *ReleaseResidentPrg ARGs( (BPTR) );
\ %? /*
\ %? * Added V36 of arp.library *
\ %? */
\ %? LONG C_Args SPrintf ARGs( (char *, char *,) );
\ %? LONG GetKeywordIndex ARGs( (char *, char *) );
\ %? struct Library C_Args *ArpOpenLibrary ARGs( (char *, LONG) );
\ %? struct FileRequester C_Args *ArpAllocFreq ARGs( (VOID) );
\ %? /*
\ %? * Check if we should do the pragmas... *
\ %? */
\ %? #ifndef NO_PRAGMAS
\ %? #ifndef PROTO_ARP_H
\ %? #include <Proto/ARP.h>
\ %? #endif PROTO_ARP_H
\ %? #endif NO_PRAGMAS
\ %? #endif LIBRARIES_ARPBASE_H